import axios from 'axios'
export function request(config) {
    const install = axios.create({
        baseURL: '/api',
        timeOut: 5000
    })
    install.interceptors.request.use(data => {
        let token = localStorage.getItem("token");
        if (token) {  // 判断是否存在token，如果存在的话，则每个http header都加上token 
            data.headers.common['token'] = `${token}`;
        }
        return data
    }, err => {
        return err
    })
    install.interceptors.response.use(data => {
        return data
    }, err => {
        return err
    })
    return install(config)
}


